package com.fwtai.controller.web;

import com.fwtai.bean.PageFormData;
import com.fwtai.service.web.WelcomeService;
import com.fwtai.tool.ToolClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 欢迎页统计
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @创建日期 2021-07-21 17:49:27
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@RequestMapping("/welcome")
public class WelcomeController{

    @Resource
	private WelcomeService welcomeService;

    @PreAuthorize("hasAuthority('welcome_btn_getAllUser')")
    @GetMapping("/getAllUser")
    public void getAllUser(final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.getAllUser(),response);
    }

    @PreAuthorize("hasAuthority('welcome_btn_getShareTotal')")
    @GetMapping("/getShareTotal")
    public void getShareTotal(final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.getShareTotal(),response);
    }

    @PreAuthorize("hasAuthority('welcome_btn_getRegisterMonth')")
    @GetMapping("/getRegisterMonth")
    public void getRegisterMonth(final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.getRegisterMonth(),response);
    }

    @PreAuthorize("hasAuthority('welcome_btn_getBrowseDay')")
    @GetMapping("/getBrowseDay")
    public void getBrowseDay(final String day,final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.getBrowseDay(day),response);
    }

    @PreAuthorize("hasAuthority('welcome_btn_getBrowseMonth')")
    @GetMapping("/getBrowseMonth")
    public void getBrowseMonth(final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.getBrowseMonth(),response);
    }

    //合伙人-获取我的推广团队
    @PreAuthorize("hasAuthority('welcome_btn_getShareTeam')")
    @GetMapping("/getShareTeam")
    public void getShareTeam(final HttpServletRequest request,final HttpServletResponse response){
        ToolClient.responseJson(welcomeService.listShareInfo(new PageFormData(request)),response);
    }

    /**首页数据概览统计数据 待兑换积分 待发货订单数量 用户总数量 积分商城支付订单数量*/
    @PreAuthorize("hasAuthority('welcome_btn_getDataOverview')")
    @GetMapping("/getDataOverview")
    public void getDataOverview(final HttpServletResponse response){
      ToolClient.responseJson(welcomeService.getDataOverview(),response);
    }

}